/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.trumah.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import br.com.trumah.model.enums.TipoNecessidades;

/**
 *
 * @author rafaell
 */
@Entity
@Table(name = "Beneficiario")
@NamedQueries({@NamedQuery(name = "Beneficiario.findAll", query = "SELECT b FROM Beneficiario b"), @NamedQuery(name = "Beneficiario.findById", query = "SELECT b FROM Beneficiario b WHERE b.id = :id"), @NamedQuery(name = "Beneficiario.findByNecessidades", query = "SELECT b FROM Beneficiario b WHERE b.necessidades = :necessidades")})
public class Beneficiario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "necessidades")
    @Enumerated(EnumType.STRING)
    private TipoNecessidades necessidades;
    @JoinColumn(name = "pessoa_id", referencedColumnName = "id")
    @ManyToOne
    private Pessoa pessoaId;
    @JoinColumn(name = "endereco_id", referencedColumnName = "id")
    @ManyToOne
    private Endereco enderecoId;
    @OneToMany(mappedBy = "beneficiarioId")
    private List<Doacao> doacaoList;
    @OneToMany(mappedBy = "beneficiarioId")
    private List<Dependente> dependenteList;

    public Beneficiario() {
    }

    public Beneficiario(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public TipoNecessidades getNecessidades() {
        return necessidades;
    }

    public void setNecessidades(TipoNecessidades necessidades) {
        this.necessidades = necessidades;
    }

    public Pessoa getPessoaId() {
        return pessoaId;
    }

    public void setPessoaId(Pessoa pessoaId) {
        this.pessoaId = pessoaId;
    }

    public Endereco getEnderecoId() {
        return enderecoId;
    }

    public void setEnderecoId(Endereco enderecoId) {
        this.enderecoId = enderecoId;
    }

    public List<Doacao> getDoacaoList() {
        return doacaoList;
    }

    public void setDoacaoList(List<Doacao> doacaoList) {
        this.doacaoList = doacaoList;
    }

    public List<Dependente> getDependenteList() {
        return dependenteList;
    }

    public void setDependenteList(List<Dependente> dependenteList) {
        this.dependenteList = dependenteList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Beneficiario)) {
            return false;
        }
        Beneficiario other = (Beneficiario) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "trumah.Beneficiario[id=" + id + "]";
    }

}
